<?php
class Oplog {
	
	public function __construct($registry) {
		$this->db = $registry->get ( 'db' );
		$this->user = $registry->get ( 'user' );
		$this->request = $registry->get ( 'request' );
	}
	
	public function add_log($type) {
		$data = mysql_real_escape_string((json_encode ( $this->request->post )));
		if (! $data) {
			$data = mysql_real_escape_string(json_encode ( $this->request->get ));
		}
		$this->db->query ( "INSERT INTO op_log(uid,username,route,content,op_time,type)VALUES({$this->user->getId()},'{$this->user->getUserName()}','{$this->request->get['route']}','{$data}',NOW(),{$type}) " );
	}
}

?>